package com.gitee.wsl.reflect

import kotlin.reflect.KProperty

fun <T> resettableLazy(initializer: () -> T) = ResettableDelegate(initializer)

class ResettableDelegate<T>(private val initializer: () -> T) {
         private var lazyRef = lazy(initializer)

          operator fun getValue(thisRef: Any?, property: KProperty<*>): T {
             return lazyRef.getValue(thisRef, property)
         }

         fun reset() {
             lazyRef = lazy(initializer)
         }
}